package com.bw.controller;

import com.bw.domain.Sugar;
import com.bw.domain.SugarTwo;
import com.bw.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {
    @Autowired
    SugarService sugarService;

    @RequestMapping("list1")
    public Map t1(){
        Double dou = sugarService.getSugarList1();
        Map map = new HashMap<>();
        map.put("status",0);
        map.put("data",dou);
        return map;
    }

    @RequestMapping("list2")
    public Map t2(){
        List<Sugar> list = sugarService.getSugarList2();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("list3")
    public String t3(){
        List<SugarTwo> list = sugarService.getSugarList3();
        List<String> list1 = new ArrayList<>();
        list1.add("机构");
        list1.add("完运里程");
        list1.add("完运次数");
        list1.add("完运时长");
        list1.add("每次平均时长");
        list1.add("每次平均里程");
        return SugarUtil.getTablePlayData(list1,list);
    }

    @RequestMapping("list4")
    public Map t4(){
        List<Sugar> list = sugarService.getSugarList4();
        return SugarUtil.getMapData(list);
    }

    @RequestMapping("list5")
    public Map t5(){
        List<Sugar> list = sugarService.getSugarLis5();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("list6")
    public Map t6(){
        List<Sugar> list = sugarService.getSugarLis6();
        return SugarUtil.getBarData(list);
    }

    @RequestMapping("list7")
    public Map t7(){
        List<Sugar> list = sugarService.getSugarList7();
        Map map = new HashMap<>();
        map.put("status",0);
        map.put("data",list);
        return map;
    }

    @RequestMapping("list8")
    public Map t8(){
        Double dou = sugarService.getSugarList8();
        Map map = new HashMap<>();
        map.put("status",0);
        map.put("data",dou);
        return map;
    }
}
